Skip to content

Fix component foreign key migrations for bigint IDs - #416

Merged
jbrooksuk merged 1 commit into
mainfrom
claude/fix-broken-migration-onaao4
Aug 5, 2026
Merged

Fix component foreign key migrations for bigint IDs#416
jbrooksuk merged 1 commit into
mainfrom
claude/fix-broken-migration-onaao4

Conversation

@jbrooksuk

Copy link
Copy Markdown
Member

Summary

  • match component_id to the existing components.id column type in the component checks and status changes migrations
  • add migration coverage for the status changes foreign key

Why

Early Cachet 3 installations may use bigint component IDs, while these migrations previously created unsigned integer foreign keys. MySQL and MariaDB reject that mismatch with errno 150.

Fixes cachethq/cachet#4625

Validation

  • git show --check 3e1c46d

The component_checks and component_status_changes migrations hardcoded
component_id as an unsigned integer, but components.id is a big integer
on databases created by early 3.x builds. MySQL and MariaDB refuse a
foreign key whose column type differs from the referenced column, so
migrating those installations failed with errno 150. Both migrations now
read the actual type of components.id and create component_id to match.

Fixes cachethq/cachet#4625

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Poo3yQZ5oUvb7R7mzKjpXf
@jbrooksuk
jbrooksuk marked this pull request as ready for review August 5, 2026 12:29
@jbrooksuk
jbrooksuk merged commit b6463b1 into main Aug 5, 2026
23 checks passed
@jbrooksuk
jbrooksuk deleted the claude/fix-broken-migration-onaao4 branch August 5, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

migration tells Can't create table cachet.component_status_changes (errno: 150 "Foreign key constraint is incorrectly formed")

2 participants